
export const requestutil = function(url, data, method = "GET", showLoading = true, header = {
}, ) {
	const sessionData = uni.getStorageSync('sessionData')
	const link = `${url}`;
	var promise = new Promise(function(resolve, reject) {
		if (showLoading) {
			//uni.showLoading({
			//	mask: true
			//});
		}
		uni.request({
			url: link,
			method: method.toUpperCase(),
			data: data,
			dataType: 'json',
			header: header,
			success(data) {
				// console.log(data.data.msg, data.data.status, data.data.status == '-1')
				if (data.data.status == '-1') {
					uni.showToast({
						title: data.data.msg,
						duration: 2000,
						icon: 'none'
					});
					// 未登录
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/login/loginAndRegister'

						})
					}, 2000)
					// console.log(data, "fff")
				} else {
					resolve(data);
				}

				uni.hideLoading()

			},
			fail: function(data) {
				uni.hideLoading()
				reject(data);
			}
		})
	})
	return promise
}
